from __future__ import unicode_literals

from django.db import models
from django.contrib.auth.models import User


# Create your models here.


class Location(models.Model):
    location_id = models.IntegerField(primary_key=True)
    location_name = models.CharField(max_length=40, unique=True)
    location_introduction = models.CharField(max_length=256, default='')


class Flight(models.Model):
    flight_id = models.IntegerField(primary_key=True)
    src = models.ForeignKey(Location, related_name='flight_src')
    dest = models.ForeignKey(Location, related_name='flight_dest')
    departure = models.DateTimeField()
    arrival = models.DateTimeField()
    price = models.DecimalField(max_digits=8, decimal_places=2)
    volume = models.IntegerField()
    reserve = models.ManyToManyField(User, related_name='flight_reserve')


class Bus(models.Model):
    bus_id = models.IntegerField(primary_key=True)
    src = models.ForeignKey(Location, related_name='bus_src')
    dest = models.ForeignKey(Location, related_name='bus_dest')
    departure = models.DateTimeField()
    arrival = models.DateTimeField()
    price = models.DecimalField(max_digits=8, decimal_places=2)
    volume = models.IntegerField()
    reserve = models.ManyToManyField(User, related_name='bus_reserve')


class Hotel(models.Model):
    hotel_id = models.IntegerField(primary_key=True)
    location = models.ForeignKey(Location)
    price = models.DecimalField(max_digits=8, decimal_places=2)
    volume = models.IntegerField()
    reserve = models.ManyToManyField(User, related_name='hotel_reserve')


